package com.example.parking.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.parking.entity.Order;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT * FROM stop_order WHERE user_id = #{userId} AND state = 0")
    Order getById(Integer userId);

    @Select("SELECT * FROM stop_order WHERE user_id = #{userId}")
    List<Order> getByLogin(Integer userId);

    @Select("SELECT * FROM stop_order WHERE UNIX_TIMESTAMP(begin_time) >= UNIX_TIMESTAMP(#{beginTime}) " +
            "and UNIX_TIMESTAMP(end_time) <= UNIX_TIMESTAMP(#{endTime}) and state = 1 ")
    List<Order> getByDate(String beginTime, String endTime);

    @Select("SELECT * FROM stop_order WHERE state = 1")
    List<Order> getList();
}
